<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Overview of poly_int (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Overview of poly_int (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Overview of poly_int (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="poly_005fint.html#poly_005fint" rel="up" title="poly_int">
<link href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" rel="next" title="Consequences of using poly_int">
<link href="poly_005fint.html#poly_005fint" rel="prev" title="poly_int">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<a name="Overview-of-poly_005fint"></a>
<div class="header">
<p>
Next: <a href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" accesskey="n" rel="next">Consequences of using <code>poly_int</code></a>, Up: <a href="poly_005fint.html#poly_005fint" accesskey="u" rel="up">poly_int</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Overview-of-poly_005fint-1"></a>
<h3 class="section">10.1 Overview of <code>poly_int</code></h3>

<a name="index-poly_005fint_002c-runtime-value"></a>
<p>We define indeterminates <var>x1</var>, &hellip;, <var>xn</var> whose values are
only known at runtime and use polynomials of the form:
</p>
<div class="smallexample">
<pre class="smallexample"><var>c0</var> + <var>c1</var> * <var>x1</var> + &hellip; + <var>cn</var> * <var>xn</var>
</pre></div>

<p>to represent a size or offset whose value might depend on some
of these indeterminates.  The coefficients <var>c0</var>, &hellip;, <var>cn</var>
are always known at compile time, with the <var>c0</var> term being the
&ldquo;constant&rdquo; part that does not depend on any runtime value.
</p>
<p>GCC uses the <code>poly_int</code> class to represent these coefficients.
The class has two template parameters: the first specifies the number of
coefficients (<var>n</var> + 1) and the second specifies the type of the
coefficients.  For example, &lsquo;<samp>poly_int&lt;2, unsigned short&gt;</samp>&rsquo; represents
a polynomial with two coefficients (and thus one indeterminate), with each
coefficient having type <code>unsigned short</code>.  When <var>n</var> is 0,
the class degenerates to a single compile-time constant <var>c0</var>.
</p>
<a name="index-poly_005fint_002c-template-parameters"></a>
<a name="index-NUM_005fPOLY_005fINT_005fCOEFFS"></a>
<p>The number of coefficients needed for compilation is a fixed
property of each target and is specified by the configuration macro
<code>NUM_POLY_INT_COEFFS</code>.  The default value is 1, since most targets
do not have such runtime invariants.  Targets that need a different
value should <code>#define</code> the macro in their <samp><var>cpu</var>-modes.def</samp>
file.  See <a href="Back-End.html#Back-End">Back End</a>.
</p>
<a name="index-poly_005fint_002c-invariant-range"></a>
<p><code>poly_int</code> makes the simplifying requirement that each indeterminate
must be a nonnegative integer.  An indeterminate value of 0 should usually
represent the minimum possible runtime value, with <var>c0</var> specifying
the value in that case.
</p>
<p>For example, when targetting the Arm SVE ISA, the single indeterminate
represents the number of 128-bit blocks in a vector <em>beyond the minimum
length of 128 bits</em>.  Thus the number of 64-bit doublewords in a vector
is 2 + 2 * <var>x1</var>.  If an aggregate has a single SVE vector and 16
additional bytes, its total size is 32 + 16 * <var>x1</var> bytes.
</p>
<p>The header file <samp>poly-int-types.h</samp> provides typedefs for the
most common forms of <code>poly_int</code>, all having
<code>NUM_POLY_INT_COEFFS</code> coefficients:
</p>
<a name="index-poly_005fint_002c-main-typedefs"></a>
<dl compact="compact">
<dt><code>poly_uint16</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>unsigned short</code> coefficients.
</p>
</dd>
<dt><code>poly_int64</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>HOST_WIDE_INT</code> coefficients.
</p>
</dd>
<dt><code>poly_uint64</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>unsigned HOST_WIDE_INT</code> coefficients.
</p>
</dd>
<dt><code>poly_offset_int</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>offset_int</code> coefficients.
</p>
</dd>
<dt><code>poly_wide_int</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>wide_int</code> coefficients.
</p>
</dd>
<dt><code>poly_widest_int</code></dt>
<dd><p>a &lsquo;<samp>poly_int</samp>&rsquo; with <code>widest_int</code> coefficients.
</p></dd>
</dl>

<p>Since the main purpose of <code>poly_int</code> is to represent sizes and
offsets, the last two typedefs are only rarely used.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Consequences-of-using-poly_005fint.html#Consequences-of-using-poly_005fint" accesskey="n" rel="next">Consequences of using <code>poly_int</code></a>, Up: <a href="poly_005fint.html#poly_005fint" accesskey="u" rel="up">poly_int</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
